package Maps 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;	
	import Utils.TextUtils;
	/**
	 * ...
	 * @author Serg de Adelantado
	 */
	public class TooltipField extends Sprite 
	{
		private var FLabel:TextField;
		private var FValue:TextField;
		private var FFormat:TextFormat;
		
		public function TooltipField(ALabel:String):void
		{
			FFormat = new TextFormat('Calibri', 14, 0, true);
			FLabel = new TextField();
			FLabel.defaultTextFormat = FFormat;
			FLabel.text = ALabel + ':';
			TextUtils.AdjustTextSize(FLabel);
			addChild(FLabel);
			FValue = new TextField();
			FFormat.bold = false;
			FValue.defaultTextFormat = FFormat;
			Value = '0';			
			addChild(FValue);	
			mouseEnabled = mouseChildren = false;
		}
		
		public function DoAlign(AMaxWidth:Number = 0):void
		{
			if (AMaxWidth > 0)
				FValue.x = AMaxWidth - FValue.width;
			else
				FValue.x = FLabel.width + 10;
		}
		
		public function set Value(AValue:String):void 
		{
			FValue.text = AValue;
			TextUtils.AdjustTextSize(FValue);
			FValue.x = FLabel.width + 10;
		}
	}
}